package com.song.aop;

import com.song.dao.impl.AdministratorDaoImpl;
import com.song.polo.Administrator;
import com.song.service.impl.AdministratorServiceImpl;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 管理员的服务功能。面向AOP
 *
 * @author song
 */
@Component
@Aspect
public class AdministratorAspect {
    @Autowired
    private AdministratorDaoImpl administratorDao;

    /**
     * 管理员注册时的切入dian
     */
    @Pointcut("execution(* com.song.service..*.register*(..))")
    private void registerPointCat() {
    }

    @Pointcut("execution(* com.song.service..*.login*(..))")
    private void loginPointCat(){
    }

    /**
     * 切入的功能
     */
    @Before("registerPointCat()")
    public void beforeRegister(JoinPoint jp) {
        System.out.println("注册前判断-------");
        //获取被代理的对象
        AdministratorServiceImpl target = (AdministratorServiceImpl) jp.getTarget();
        System.out.println(target);
        //判断该对象是不是Administrator类

    }

}
